package io.renren.modules.hos.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import org.springframework.stereotype.Service;
import java.util.Map;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import io.renren.common.utils.PageUtils;
import io.renren.common.utils.Query;

import io.renren.modules.hos.dao.TitleAmountDao;
import io.renren.modules.hos.entity.TitleAmountEntity;
import io.renren.modules.hos.service.TitleAmountService;


@Service("titleAmountService")
public class TitleAmountServiceImpl extends ServiceImpl<TitleAmountDao, TitleAmountEntity> implements TitleAmountService {

    @Override
    public PageUtils queryPage(Map<String, Object> params) {
        IPage<TitleAmountEntity> page = this.page(
                new Query<TitleAmountEntity>().getPage(params),
                new QueryWrapper<TitleAmountEntity>()
        );

        return new PageUtils(page);
    }

    @Override
    public Integer selectAmountByTitle(String doctorTitle) {
        LambdaQueryWrapper<TitleAmountEntity> queryWrapper = new LambdaQueryWrapper<>();
        queryWrapper.eq(TitleAmountEntity::getDoctorTitle, doctorTitle);
        TitleAmountEntity titleAmountEntity = baseMapper.selectOne(queryWrapper);

        return titleAmountEntity.getAmount();
    }

}